module.exports = class extends think.Model {
    async add (data) {
        const db = think.mongoose('mongo/deal')
        let doc = new db(data)
        let result = await doc.save()
        return result
    }
    async deal (id) {
        let _id = think.objId(id)
        const db = think.mongoose('mongo/deal')
        let deal = await db.findOne({_id})
        return deal
    }
    async all (uid) {
        const db = think.mongoose('mongo/deal')
        let list = await db.find({uid, status: 1})
        return list
    }
    async list (uid, type) {
        const db = think.mongoose('mongo/deal')
        let list = await db.find({uid, type}).sort({_id: -1})
        return list
    }
    async setPay (id, status, remark) {
        let _id = think.objId(id)
        const db = think.mongoose('mongo/deal')
        await db.updateOne({_id}, {
            status,
            remark
        })
    }
};
